<?php

class Sistema_Form_Projetos extends Zend_Form {

    public function init() {
        $front = Zend_Controller_Front::getInstance();
        $controller = $front->getRequest()->getControllerName();
        $module = $front->getRequest()->getModuleName();
        $url = $front->getBaseUrl().'/'.$module.'/'.$controller;

        $this->setName('form_pdr');

        $id = $front->getRequest()->getParam('id', 0);
        $amb_id = $front->getRequest()->getParam('amb_id', 0);
        
        $url .= '/index/amb_id/'.$amb_id;
        
        $el = new Zend_Form_Element_Hidden('PRT_ID', array('disableLoadDefaultDecorators' => true));
        $el->addDecorators(array(array('ViewHelper'), array('Errors')))->addFilter('Int');
        $this->addElement($el);

        $el = new Zend_Form_Element_Text('PRT_NOM');
        $el->setLabel('Nome')->setRequired(true);
        $el->setAttrib('required', '');
        $this->addElement($el);
        
        /*
        $img = glob('public/upload/'.$controller.'/'.$id.'.*');
        if(is_array($img))
        foreach($img as $src) {
            $el = new Zend_Form_Element('img',array( 'helper'=>'formNote', 'value'=>'<img height="200" style="max-width:600px" src="'.$front->getBaseUrl().'/'.$src.'" />' ));
            $this->addElement($el);
        }
        $el = new Zend_Form_Element_File('PRT_FILE');
        $el->setLabel('Imagem - Resolução: 1920 x 1080');
        $el->addValidator('Extension', false, array('jpg', 'jpeg', 'png', 'gif'));
        $this->addElement($el);
        */
        
        $el = new Zend_Form_Element_Text('PRT_ORD');
        $el->setLabel('Ordem')->setRequired(true);
        $el->setAttrib('class', 'numero nummin');
        $el->setAttrib('maxlength', '3');
        $el->setAttrib('required', '');
        $this->addElement($el);
        
        
        $el = new Zend_Form_Element_Checkbox('PRT_STA',array('checked'=>'checked'));
        $el->setLabel('Ativo');
        $this->addElement($el);
        
        $btn = new Zend_Form_Element_Submit('Salvar', array('disableLoadDefaultDecorators' => true));
        $btn->setLabel('Salvar');
        $btn->addDecorators(array(array('ViewHelper'), array('Errors')));
        $btn->setAttrib('id', 'submitbutton');
        $btn->setAttrib('class', 'btn-frm');
        $this->addElement($btn);

        $btn = new Zend_Form_Element_Button('Cancelar', array('disableLoadDefaultDecorators' => true));
        $btn->setDecorators(array(array('Description', array('escape' => false, 'tag' => false))));
        $btn->setDescription('<a href="' . $url . '" class="btn-frm">Voltar</a>');
        $btn->setAttrib('id', 'btncancel');
        $btn->setAttrib('class', 'btn-frm');
        $this->addElement($btn);
    }

}
